<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Zip 上下文选项列表</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="context.params.html">« Context 参数</a></li>
      <li style="float: right;"><a href="wrappers.html">支持的协议和封装协议 »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="context.html">上下文（Context）选项和参数</a></li>
    <li>Zip 上下文选项列表</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="context.zip" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Zip 上下文选项</h1>
  <p class="refpurpose"><span class="refname">Zip 上下文选项</span> &mdash; <span class="dc-title">Zip 上下文选项列表</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-context.zip-description">
  <h3 class="title">说明</h3>
  <p class="para">
   Zip 上下文选项可用于 <code class="literal">zip</code> 包装器。
  </p>
 </div>

 
 <div class="refsect1 options" id="refsect1-context.zip-options">
  <h3 class="title">可选项</h3>
  <p class="para">
   <dl>
    
     <dt id="context.zip.password"><code class="parameter">password</code></dt>

     <dd>

      <p class="para">
       用于指定加密归档的密码。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 changelog" id="refsect1-context.zip-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PHP 7.2.0, PECL zip 1.14.0</td>
       <td>
        添加 <code class="parameter">password</code>。
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-context.zip-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="context.zip.example-password">
    <p><strong>示例 #1 基础 <code class="parameter">password</code> 用法示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;读取加密归档<br /></span><span style="color: #0000BB">$opts&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'zip'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'password'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'secret'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;),<br />);<br /></span><span style="color: #FF8000">//&nbsp;创建上下文...<br /></span><span style="color: #0000BB">$context&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">stream_context_create</span><span style="color: #007700">(</span><span style="color: #0000BB">$opts</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;...并且使用它读取数据<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'zip://test.zip#test.txt'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$context</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>

 
</div></div></div></body></html>